package com.hc.service.impl;

import com.hc.bean.ProductInfo;
import com.hc.dao.ProductInfoDao;
import com.hc.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ProductInfoServiceImpl implements ProductInfoService {
    @Autowired
    private ProductInfoDao productInfoDao;

    @Override
    public List<ProductInfo> getProductList(Map<String,Object> params) {
        return productInfoDao.getProductList(params);
    }

    @Override
    public Integer getCountByParam(Map<String,Object> params) {
        return productInfoDao.getProductInfoCount(params);
    }

    @Override
    public Boolean addProductInfo(ProductInfo productInfo) {
        if (productInfoDao.addProductInfo(productInfo)>0)
            return true;
        return false;
    }

    @Override
    public Boolean updateProductInfo(ProductInfo productInfo) {
        if(productInfoDao.updateProductInfo(productInfo)>0)
            return true;
        return false;
    }

    @Override
    public Boolean changeProductStatus(Integer status,String ids) {
        if(productInfoDao.changeProductStatus(status,ids)>0)
            return true;
        return false;
    }

    @Override
    public List<ProductInfo> getOnSaleProduct() {
        return productInfoDao.getOnSaleProduct();
    }

    @Override
    public double getPriceById(int pid) {
        return productInfoDao.getPriceById(pid);
    }
}
